<?php
//简单管理页面范例，在你的管理页面引用coresection/checkA.php就OK，当然，不要忘了添加注销登录的链接
include_once '../coresection/checkA.php';
?>

<?
include_once("../../config_controller.php");
$host = $_SERVER['HTTP_HOST']; //取得进入所输入的域名
$theme_folder = host_theme($host);

include_once '../../front/'.$theme_folder.'/connection.php';include_once '../coresection/check_session.php';;
?>

<?php include_once("function.php"); ?>
<?php include "../../front/".$theme_folder."/config.php"; ?>

<?php
if(!isset($_SESSION)){
session_start();
}

$act = $_REQUEST['act'];

$search_val = $_REQUEST['val'];

$result = array('error' => 0, 'message' => '', 'content' => '');

if(!$search_val){
		
	$result['error'] = 1;
	$result['message'] = '请选择相关类型';

	die(json_encode($result));
	exit;	
}


//公用模式
global $table_Prefix;

if($search_val){
	
	$search_val_arr = explode(',',$search_val);
	
	$search_val_sql = '';
	
	foreach($search_val_arr as $val){
		if($search_val_sql != ''){
			$search_val_sql.= ",'".$val."'";
		}
		else{
			$search_val_sql.= "'".$val."'";
		}
		
	}
	
}




if($act == 'search_detail' ){ 
	
	$new_detail_list = array();
	
	$new_detail_list = array();
	
	$detail_list = select_lines_all_items($table_Prefix . "detail", ' nid  desc ',"belong in( $search_val_sql ) and publish = 1 "); 
	
	$plate_list = select_lines_all_items($table_Prefix . "plate", ' nid  desc '); 
	
	
	foreach($plate_list as $key=>$val){
		$new_plate_list[$val['mid']]['name'] = $val['name'];
		$new_plate_list[$val['mid']]['mid'] = $val['mid'];
	}

	if(!$detail_list){
			
		$result['error'] = 1;
		$result['message'] = '当前查询信息没结果';
		die(json_encode($result));
		exit;	
	}
	
	foreach($detail_list as $key=>$val){
		$new_detail_list[$key]['title'] = $val['name'].$val['model'].'['.$new_plate_list[$val['belong']]['name'].']';
		$new_detail_list[$key]['value'] = $val['nid'];
	}
	
	$result['error'] = 0;
	$result['message'] = '';
	$result['content'] = $new_detail_list;
	die(json_encode($result));
	exit;	

}
	
	

?>